package vfs.persist.association.impl;


import java.sql.Connection;
import vfs.filter.VFSFilter;
import vfs.obj.entity.VFSUser;
import vfs.obj.entity.VFSNode;
import vfs.persist.association.VFSNodeOwnedByUserManager;
import vfs.persist.entity.build.impl.VFSUserBuilder;
import vfs.persist.entity.build.impl.VFSNodeBuilder;
import java.util.Iterator;

/**
 *
 * @author Matthew Eavenson <durandal@uga.edu>
 */
public class VFSNodeOwnedByUserManagerImpl implements VFSNodeOwnedByUserManager{
    
    private VFSAssociationManagerImpl<VFSNode, VFSUser> am;
    
    public VFSNodeOwnedByUserManagerImpl(Connection conn){
        am = new VFSAssociationManagerImpl<VFSNode, VFSUser>(conn, new VFSNodeBuilder(), 
                                                 new VFSUserBuilder(), 
                                        "vfsNode", null, "ownedBy");
    }
    
    @Override
    public Iterator<VFSNode> getNodes(VFSUser user, VFSFilter filter){
        return am.findTM1(user, filter);
    }
    
    @Override
    public VFSUser getOwner(VFSNode node){
        return am.findUM1(node);
    }
    
    @Override
    public void setOwner(VFSNode node, VFSUser user){
        am.persistM1(node, user);
    }
    
}
